<?xml version="1.0" encoding="UTF-8"?>

<ui:composition 
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:c="http://java.sun.com/jsp/jstl/core">

    <div>
        <h:panelGroup layout="block" rendered="#{not empty subjectThread.currentSubject.myFather}">
            <h:outputLink value="#{subjectThread.basePath}/index.xhtml?uuid=#{subjectThread.currentSubject.myFather.uuid}">
                Retour
            </h:outputLink>
        </h:panelGroup>
        
        <h2><h:outputText value="#{subjectThread.currentSubject.title}"/></h2>
        <h:form id="addSubSubject" rendered="#{empty subjectThread.currentSubject.myThreads}">
            <h:panelGroup layout="block">
                <h:outputLabel value="Ajout d'une sous-catégorie"/>
                <h:inputText value="#{subjectThread.newSubject.title}" id="title"/>
                <h:commandLink value="Ajouter" action="#{subjectThread.addSubSubject()}"/>
            </h:panelGroup>
        </h:form>

        <h:panelGroup layout="block" rendered="#{empty subjectThread.currentSubject.mySons}">
            <h:outputLink value="#{subjectThread.basePath}/threads/newThread.xhtml?uuid=#{subjectThread.currentSubject.uuid}">
                Ajouter une thread
            </h:outputLink>
        </h:panelGroup>

        
        <h:panelGroup rendered="${not empty subjectThread.currentSubject.mySons}" layout="block">
            <h3>Sous-catégories</h3>
            <h:dataTable value="#{subjectThread.currentSubject.mySons}" var="subject">
                <h:column>
                    <h:form>Link: 
                        <h:outputLink value="#{subjectThread.basePath}/index.xhtml?uuid=#{subject.uuid}">
                            <h:outputText value="#{subject.title}"/>
                        </h:outputLink>
                    </h:form>
                </h:column>
            </h:dataTable>
        </h:panelGroup>
        <h:panelGroup rendered="${not empty subjectThread.currentSubject.myThreads}" layout="block">
            <h3>Threads</h3>
            <h:dataTable value="#{subjectThread.currentSubject.myThreads}" var="thread">
                <h:column>
                    <h:form>Thread:
                        <h:outputLink value="#{subjectThread.basePath}/threads/thread.xhtml?uuid=#{thread.uuid}">
                            <h:outputText value="#{thread.title}"/>
                        </h:outputLink>
                    </h:form>
                </h:column>
            </h:dataTable>
        </h:panelGroup>
    </div>
</ui:composition>
